package com.lxp.base.net.builder;


import com.lxp.base.net.self.IBaseHttp;

import java.io.File;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Created by lxp on 2017/6/4.
 */

public abstract class BaseParamBuilder<T extends BaseParamBuilder> extends BaseBuilder<T> {

    protected Map<String, Object> mParams;

    public BaseParamBuilder(IBaseHttp mHttp) {
        super(mHttp);
    }

    /**
     * set Map params
     *
     * @param params
     * @return
     */
    public T params(Map<String, Object> params) {
        this.mParams = params;
        return (T) this;
    }

    /**
     * add param
     *
     * @param key param key
     * @param val param val
     * @return
     */
    public T addParam(String key, String val) {
        if (this.mParams == null) {
            mParams = new LinkedHashMap<>();
        }
        mParams.put(key, val);
        return (T) this;
    }


    /**
     * add one upload file
     *
     * @param key  file key
     * @param file file
     * @return
     */
    public T addFile(String key, File file) {
        if (this.mParams == null) {
            mParams = new LinkedHashMap<>();
        }
        mParams.put(key, file);
        return (T) this;
    }


}
